def numsplit(num):
    num *= 10
    s = [(num % (10 ** (i + 1))) // (10 ** i) for i in range(1, len(str(num)))]
    s.sort()
    return s


def detect(num):
    target = numsplit(num)
    for i in range(6, 1, -1):
        if target != numsplit(i * num):
            return False
    return True


if __name__ == '__main__':
    for i in range(1, 100000):
        for j in range(10 ** i):
            if detect(10 ** i + j):
                print(10 ** i + j)
                exit(0)
